package com.example.controller;

import com.example.pojo.User;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2024-03-02
 * Time: 23:47
 */

// Restful 风格

@RestController
@RequestMapping("/user")
public class UserController {


    @GetMapping("/page")
    public List<User> page(@RequestParam(required = false, defaultValue = "1") int page,
                           @RequestParam(required = false, defaultValue = "10") int size) {

        System.out.println("page: " + page + ", size: " + size);
        return null;
    }


    @PostMapping
    public User save(@RequestBody User user) {
        return user;
    }

    @GetMapping("/{id}")
    public User detail(@PathVariable("id") Integer id) {
        return null;
    }


    @PutMapping
    public User update(@RequestBody User user) {
        return user;
    }

    @DeleteMapping("/{id}")
    public User delete(@PathVariable Integer id) {
        return null;
    }

    @GetMapping("/search")
    public List<User> search(String keyword,
                             @RequestParam(required = false, defaultValue = "1") int page,
                             @RequestParam(required = false, defaultValue = "10") int size) {
        return null;
    }

}
